ObjectiveIn general, we can navigate to the target element with simple XPath, but it is difficult to navigate in a simple way for some without ID and no name, and other properties are dynamic.In this case, we need to use xpath1.0 built-in functions
For example, a UL has 10 Li, and the 3rd Li has a special style (such as red color, the other is black). I want all other li--not including red li--color also set to red, at this time, you need to get red Li's all sibling nodes.
Brother, is peace
For example, a UL has 10 Li, and the 3rd Li has a special style (such as red color, the other is black). I want all other li--not including red li--color also set to red, at this time, you need to get red Li's all sibling nodes.
Brother, is peace
Js gets the implementation method of all the sibling nodes of the element. js nodes
For example, there are 10 li in a ul, and 3rd li have special styles (for example, the color is red and others are black ). I want to set the color of all other
For example, a UL has 10 Li, and the 3rd Li has a special style (such as the color is red, the other is black). I want all the other li--not including the red li--color also set to red, at this time, you need to get red Li all the Brothers
The js method is much more troublesome than the jq method, mainly because the FF browser also regards the line feed as the dom element, the following is a small Editor to learn about jsjquery's getting the current element from the sibling level. If
First of all, the method of JS acquisition, which is more troublesome than the jquery method, followed by the jquery method for comparisonJS is a lot more troublesome than jquery, mainly because the FF browser, the FF browser, will take your newline
This example describes the jquery search sibling element approach. Share to everyone for your reference. The specific analysis is as follows:
1. Next () method
Used to search for a single sibling element immediately after each matching element,
The adjacent sibling selector (adjacent sibling selector) selects the element immediately following the other element, and both have the same parent element.Select adjacent BrothersIf you need to select an element immediately after another element,
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.